extends BallState

# ===============================================

const DURATION: float = 1
const SPRITE_SCALE: float = 0.8
const SHOT_HEIGHT: float = 5

# ===============================================

func enter() -> void:
	if ball.velocity.x >= 0:
		ball.animation_player.play("roll")
	else:
		ball.animation_player.play_backwards("roll")
	ball.animation_player.advance(0)
	ball.sprite.scale.y = SPRITE_SCALE
	ball.height = SHOT_HEIGHT
	get_tree().create_timer(DURATION).timeout.connect(
		func():
			state_transition.emit(self, State.FREE)
	)


func exit() -> void:
	ball.sprite.scale.y = 1


func process(delta: float) -> void:
	ball.move_and_collide(ball.velocity * delta)
